﻿using System;
using GpgCore;
using GpgCore.Api;
using GpgCore.Products;
using Microsoft.Xna.Framework;

namespace GpgCoreTest
{
    public class TestGodObject
    {
        public static void CreateNewGame()
        {
            MainFactory.CreateNewGame("Earth", new DateTime(1900, 1, 1), new Point(30, 30));

            var londonCell = World.Instance.Planet.PlanetMap.GetCell(10, 10);

            var oilcell = World.Instance.Planet.PlanetMap.GetCell(8, 8);
            var ironcell = World.Instance.Planet.PlanetMap.GetCell(8, 9);
            var coalcell = World.Instance.Planet.PlanetMap.GetCell(8, 10);
            var mineralscell = World.Instance.Planet.PlanetMap.GetCell(8, 11);
            
            var wheatFarmCell = World.Instance.Planet.PlanetMap.GetCell(9, 9);
            var wheatFarmCell2 = World.Instance.Planet.PlanetMap.GetCell(9, 10);
            var medherbFarmCell = World.Instance.Planet.PlanetMap.GetCell(9, 11);

            var steelFactCell = World.Instance.Planet.PlanetMap.GetCell(11, 8);
            var foodFactCell = World.Instance.Planet.PlanetMap.GetCell(11, 9);
            var medFactCell = World.Instance.Planet.PlanetMap.GetCell(11, 10);
            var plasticFactCell = World.Instance.Planet.PlanetMap.GetCell(11, 11);
            
            oilcell.Minerals = new Product(ProductType.Oil, 3000000);
            ironcell.Minerals = new Product(ProductType.IronOre, 3000000);
            coalcell.Minerals = new Product(ProductType.Coal, 3000000);
            mineralscell.Minerals = new Product(ProductType.Minerals, 3000000);

            //create england
            var england = MainFactory.CreateCountry("England");
            var london = MainFactory.CreateCity("London", england, londonCell);

            //create corporation
            var freewebtime = MainFactory.CreateCorporation("Freewebtime");
            var fwtoffice = MainFactory.CreateCityOffice(freewebtime, london);
            fwtoffice.Money = 100000000;

            //mines
            var oilScheme = MiningScheme.FindScheme(ProductType.Oil);
            var ironScheme = MiningScheme.FindScheme(ProductType.IronOre);
            var coalScheme = MiningScheme.FindScheme(ProductType.Coal);
            var mineralsScheme = MiningScheme.FindScheme(ProductType.Minerals);
            var oilWells = MainFactory.CreateMine(oilcell, oilScheme, freewebtime);
            oilWells.WorkerPayment = 10;
            oilWells.Level = 3;
            //var ironMine = MainFactory.CreateMine(ironcell, ironScheme, freewebtime);
            //ironMine.WorkerPayment = 10;
            //var coalMine = MainFactory.CreateMine(coalcell, coalScheme, freewebtime);
            //coalMine.WorkerPayment = 10;
            //var mineralsMine = MainFactory.CreateMine(mineralscell, mineralsScheme, freewebtime);
            //mineralsMine.WorkerPayment = 10;

            //farms
            var fscheme = FarmScheme.FindScheme(ProductType.Wheat);
            var fscheme2 = FarmScheme.FindScheme(ProductType.MedHerbals);
            var wheatFarm = MainFactory.CreateFarm(wheatFarmCell, fscheme, freewebtime);
            wheatFarm.WorkerPayment = 10;
            wheatFarm.Level = 8;
            var wheatFarm2 = MainFactory.CreateFarm(wheatFarmCell2, fscheme, freewebtime);
            wheatFarm2.WorkerPayment = 10;
            var medFarm = MainFactory.CreateFarm(medherbFarmCell, fscheme2, freewebtime);
            medFarm.WorkerPayment = 10;
            medFarm.Level = 5;

            //factories
            //var steelFactScheme = FactoryScheme.FindScheme(ProductType.Steal);
            //var steelFactory = MainFactory.CreateFactory(steelFactCell, steelFactScheme, freewebtime);
            //steelFactory.WorkerPayment = 10;

            var foodFactScheme = FactoryScheme.FindScheme(ProductType.Food);
            var foodFactory = MainFactory.CreateFactory(foodFactCell, foodFactScheme, freewebtime);
            foodFactory.WorkerPayment = 10;
            foodFactory.Level = 10;

            var plasticFactScheme = FactoryScheme.FindScheme(ProductType.Plastic);
            var plasticFactory = MainFactory.CreateFactory(plasticFactCell, plasticFactScheme, freewebtime);
            plasticFactory.WorkerPayment = 10;

            var medFactScheme = FactoryScheme.FindScheme(ProductType.Medicals);
            var medFactory = MainFactory.CreateFactory(medFactCell, medFactScheme, freewebtime);
            medFactory.WorkerPayment = 10;

            //Shop
            var foodShop = MainFactory.CreateShop(london, freewebtime, ProductType.Food);
            foodShop.PaymentPerWorker = 10;
            foodShop.MaxSaleCount = -1;
            foodShop.MinSalePrice = 0.01;
            foodShop.Level = 4;
            var medShop = MainFactory.CreateShop(london, freewebtime, ProductType.Medicals);
            medShop.PaymentPerWorker = 10;
            medShop.MinSalePrice = 0.01;
            medShop.MaxSaleCount = -1;
            medShop.Level = 4;
        }
    }
}
